package com.jsgt.greekfire.ui.trading.otc.adapter

import android.content.Context
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.fhx.core.utils.LogUtils
import com.jsgt.greekfire.R
import com.jsgt.greekfire.bean.OtcAdBean
import com.jsgt.greekfire.common.util.UtilsBigDecimal
import java.math.BigDecimal

class OTCSellTraddingAdapter(
    context: Context,
    layoutId: Int,
    data: MutableList<OtcAdBean.ListBean>? = null
) : BaseQuickAdapter<OtcAdBean.ListBean, BaseViewHolder>(layoutId, data) {
    override fun convert(helper: BaseViewHolder, item: OtcAdBean.ListBean) {
        var num1 = UtilsBigDecimal.mul(item?.dealAmount, 7.0, 2)
        var div = UtilsBigDecimal.div(item?.turnoverNum, item?.dealNum)
        var num = UtilsBigDecimal.mul(div, 100.0, BigDecimal.ROUND_DOWN)
        var available = UtilsBigDecimal.sub(item?.dealNum, item?.turnoverNum)
        helper.setText(R.id.tvName, item?.coinCode)
            .setText(
                R.id.tvTransactionRate,
                context.resources.getString(R.string.coinList_text2) + item?.turnoverNum
            )
            .setText(
                R.id.tvTransaction,
                context.resources.getString(R.string.otc_list_num) + num + "%"
            ).setText(
                R.id.tvId,
                "ID："+item?.spreadId
            )
            .setText(
                R.id.tvNum,
                context.resources.getString(R.string.coinList_text3) +" " + item?.dealNum + item?.coinCode
            )
            .setText(
                R.id.tvAvailable,
                context.resources.getString(R.string.available_num) +" " + available
            )
            .setText(R.id.tvCurrentPrices, "¥" + num1)
            .setText(R.id.tvCurrent, "/USDT")
    }

}